package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.basedoc.model.DriverInfo;
import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import com.eling.elcms.travel.service.IDriverInfoManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class DriverInfoController extends BaseFormController {

	@Autowired
	private IDriverInfoManager DriverManager;
	
	@RequestMapping("/api/driverinfo/save")
	@ResponseBody
	public DriverInfo save(@ModelAttribute @ModelFilling DriverInfo cond ){
		return DriverManager.save(cond);
	}
	@RequestMapping("/api/driverinfo/{PkDriverInfo}/delete")
	@ResponseBody
	public Msg delete(@PathVariable Long PkDriverInfo){
		DriverManager.remove(PkDriverInfo);
		return new Msg("删除成功");
	}
	
	@RequestMapping("/api/driverinfo/query")
	@ResponseBody
	public List<DriverInfo> query(@ModelAttribute DriverInfo cond){
		List<DriverInfo> query = DriverManager.query(cond);
		return query;
	}
	
	@RequestMapping("/api/driverinfo/search*")
	@ResponseBody
	public List<DriverInfo> search(@ModelAttribute SearchCondition sc,@ModelAttribute DriverInfo cond ){
		sc.setQueryCondition(cond);
		return DriverManager.search(sc);
	}
	
	
}
